
class_name CChargeFlow

extends EventDispatcher

signal UUID_changed(old_value, new_value) 
signal OrderNo_changed(old_value, new_value) 
signal AccountName_changed(old_value, new_value) 
signal GoodsID_changed(old_value, new_value) 
signal Amount_changed(old_value, new_value) 
signal Status_changed(old_value, new_value) 


var m_tblAlias
var bInited = false
func _init(_uuid)->void:
    self.UUID = _uuid	# 线编号
    self.OrderNo = ''	# 订单号
    self.AccountName = ''	# 账号名
    self.GoodsID = 0	# 商品id
    self.Amount = 0	# 成交金额
    self.Status = 0	# 状态

    self.m_tblAlias = {
 
    }

func UnPack(_bufferStream):
    self.UUID = _bufferStream.ReadInt64()
    self.OrderNo = _bufferStream.ReadString(TableCommonDefine.ECharLen.eCL_OrderNo)
    self.AccountName = _bufferStream.ReadString(TableCommonDefine.ECharLen.eCL_AccountName)
    self.GoodsID = _bufferStream.ReadUint32()
    self.Amount = _bufferStream.ReadUint32()
    self.Status = _bufferStream.ReadUint8()

    self.bInited = true


func GetTableName():
    return 'ChargeFlow'

func CopyFrom(other):
    self.OrderNo = other.OrderNo
    self.AccountName = other.AccountName
    self.GoodsID = other.GoodsID
    self.Amount = other.Amount
    self.Status = other.Status


func OnDataChanged( fieldName, oldValue, newValue):
    if oldValue == newValue:
        return
    
    self.DispatchEvent(fieldName, [self, oldValue, newValue])
    #  Alias
    if self.m_tblAlias[fieldName] != null:
        for i in range(self.m_tblAlias[fieldName].size()):
            self.DispatchEvent(self.m_tblAlias[fieldName][i], [self, oldValue, newValue])

func UnPackField(_fieldId, _bufferStream, _varLen ):
    if _fieldId < 0 or _fieldId == 0xffff:
        var old = CChargeFlow.new(self.m_UUID)
        old.CopyFrom( self )
        self.UnPack( _bufferStream )
        self.DispatchEvent("CChargeFlow", [self, old, self])
        return true

    print("UnPackField error tblName = ChargeFlow, className = CChargeFlow, _fieldId = ", _fieldId)
    # if _fieldId > Fields_ChargeFlowID.size():
    #     var szLog = 'CChargeFlow.UnPackField  _fieldId(%d) < 0 or _fieldId(%d) > #Fields_ChargeFlowID(%d)' % [_fieldId, _fieldId,  Fields_ChargeFlowID.size()]
    #     print(szLog)
    #     return false

    # Fields_ChargeFlowID[_fieldId].reader( self, _bufferStream, _varLen)

    return true

func AddField(_fieldId, _bufferStream):
    print( "[TABLEDATA] error AddField", "CChargeFlow", _fieldId )

    
func DelField(_fieldId ):
    print( "[TABLEDATA] error DelField", "CChargeFlow", _fieldId )

var UUID:
    set(value):
        var old = self.m_UUID
        self.UUID = _value
        self.UUID_changed.emit(old, _value)

    get:
        return self.UUID


var OrderNo:
    set(value):
        var old = self.m_OrderNo
        self.OrderNo = _value
        self.OrderNo_changed.emit(old, _value)

    get:
        return self.OrderNo


var AccountName:
    set(value):
        var old = self.m_AccountName
        self.AccountName = _value
        self.AccountName_changed.emit(old, _value)

    get:
        return self.AccountName


var GoodsID:
    set(value):
        var old = self.m_GoodsID
        self.GoodsID = _value
        self.GoodsID_changed.emit(old, _value)

    get:
        return self.GoodsID


var Amount:
    set(value):
        var old = self.m_Amount
        self.Amount = _value
        self.Amount_changed.emit(old, _value)

    get:
        return self.Amount


var Status:
    set(value):
        var old = self.m_Status
        self.Status = _value
        self.Status_changed.emit(old, _value)

    get:
        return self.Status



